#include <iostream>

using namespace std;

#define N 8
int a[8];
int total = 0;

void print()
{
	for (int i = 0; i < N; ++i)
	{
        for (int j = 0; j < a[i]; ++j)
        {
            cout << 0;
        }
        cout << 1 << endl;
	}
}

void search(int cur)
{
	if (cur == 8)
	{
		++total;
		print();
		cout << endl;
	}
	else
	{
		for (int i = 0; i < N; ++i)
		{
			int ok = 1;
			a[cur] = i;
			for (int j = 0; j < cur; ++j)
			{
				if (a[cur] ==  a[j] || cur - a[cur] == j - a[j]
						|| cur + a[cur] == j + a[j])
				{
					ok = 0;
					break;
				}
			}
			if (ok)
			{
				search(cur + 1);
			}
		}
	}
}

int main()
{
	search(0);
	cout << total << endl;
	return 0;
}
